<template>
    <div>
        <!-- <h3>采购退货</h3> -->
        <!-- 根据条件查询 -->
    <div>
      <el-form :inline="true"  class="demo-form-inline" ref="ruleForm">
        <el-form-item label="单据编号">
          <el-input v-model="documentNumber" placeholder="请输入单据编号查询"></el-input>
        </el-form-item>
        <el-form-item label="商品信息">
          <el-input v-model="productName" placeholder="请输入商品信息查询"></el-input>
        </el-form-item>
        <el-form-item label=" 单据日期 ">
          <el-date-picker
            v-model="begintime"
            type="datetimerange"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :default-time="['12:00:00']"
          ></el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="findByPage">查询</el-button>
          <el-button @click="resetForm">重置</el-button>
        </el-form-item>
      </el-form>
    </div>



    <div>
         <Table
        border
        
        :columns="columns4"
        :data="data1"
     
      >
      </Table>
    </div>

      <!-- 分页 -->
    <div style="float:right">
      <Page
        :total="dataCount"
        :page-size="pageSize"
        @on-change="changepage"
        @on-page-size-change="_nowPageSize"
        show-elevator
      />
    </div>

    </div>
</template>
<script>
import axios from "axios";
export default {
   data() {
      return {
          columns4: [
        {
          title: "#",
          key: "id"
        },
     
        {
          title: "单据编号",
          key: "documentsNumber"
        },
        {
          title: "商品信息",
          key: "productName"
        },
        {
          title: "单据日期",
          key: "documentDate"
        },
        {
            title:"商品数量",
            key:"number"
        },
        {
            title:"单价",
            key:"unitPrice"
        },
        
        {
          title: "金额合计",
          key: "totalAmount"
        },
        // {
        //   title: "状态(是否销售)",
        //   slot: "status"
        // },
       
        // {
        //   title: "用户操作",
        //   slot: "action"
        // }
        
      ],
      data1: [],

            // 分页的条件
      productName: "",
      documentNumber: "",
      begintime: [],


      //分页
        pageSize: 5, //每页显示多少条
      dataCount: 0, //总条数
      pageCurrent: 1, //当前页,
      }
   },
created(){
    this.findSalesOrderReturn();
},

   methods:{





         // 重置
    resetForm() {
      this.documentNumber = "";
      this.begintime = [];
      this.productName = "";
    },

    findByPage(){
        axios
        .post(
          "//localhost:8082/entercommodityreturn/EnterorderreturnPage?documentNumber=" +
            this.documentNumber +
            "&productName=" +
            this.productName +
            "&time=" +
            this.begintime +
            "&pageSize=" +
            this.pageSize +
            "&pageCurrent=" +
            this.pageCurrent
        )
        .then(res => {
          console.log("13123123123213")
          console.log(res.data);
          this.dataCount = res.data.countTotal;
          this.data1 = res.data.list;
         
          //当从数据库获取完毕  关闭加载特效
          this.spinShow=false;
          // this.begintime = "";
        });
    },

//查询
    findSalesOrderReturn(){
        axios
        .post(
          "//localhost:8082/entercommodityreturn/EnterorderreturnPage?documentNumber=" +
            this.documentNumber +
            "&productName=" +
            this.productName +
            "&time=" +
            this.begintime +
            "&pageSize=" +
            this.pageSize +
            "&pageCurrent=" +
            this.pageCurrent
        )
        .then(res => {
          console.log("13123123123213")
          console.log(res.data);
          this.dataCount = res.data.countTotal;
          this.data1 = res.data.list;
         
          //当从数据库获取完毕  关闭加载特效
          this.spinShow=false;
          // this.begintime = "";
        });
    },

      //点击这个,即可换页数
    changepage(index) {
  axios
        .post(
          "//localhost:8082/entercommodityreturn/EnterorderreturnPage?documentNumber=" +
            this.documentNumber +
            "&productName=" +
            this.productName +
            "&time=" +
            this.begintime +
            "&pageSize=" +
            this.pageSize +
            "&pageCurrent=" +
            index
        )
        .then(res => {
          console.log("13123123123213")
          console.log(res.data);
          this.dataCount = res.data.countTotal;
          this.data1 = res.data.list;
         
          //当从数据库获取完毕  关闭加载特效
          this.spinShow=false;
          // this.begintime = "";
        });
    },

    //每页显示的数据条数
    _nowPageSize(index) {
      //实时获取当前需要显示的条数
      this.pageSize = index;
    },


   }

}
</script>
